
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册</title>

    <link rel="stylesheet" href="${staticPath}/css/register.css">
    <link rel="stylesheet" href="${staticPath}/css/base.css">
        <script type="text/javascript" src="${request.contextPath}${staticPath}/admin/plugins/jquery/jquery-3.4.1.js"></script>
  	<script src="${request.contextPath}${staticPath}/admin/plugins/layer/layer.js"></script>
</head>

<body>
	<#include "${request.contextPath}/base/header.html">
    <div class="login_conent">
        <div class="login">
            <h1 class="loh1">用户登录</h1>
            <div class="reg_info f15">
                <div class="reg_left">
                    <p class="regp">&nbsp;→&nbsp;&nbsp;请输入您的账号信息，用于登录天地华宇系统</p>

                    <hr class="reghr" />
                    <form action="javascript:void(0)" method="post">
                    <div class="logindiv">
                        <div class="name loginnp">
                            <span>*</span><label for="">手机号：</label>
                            <input type="text" id="userTele" name="userTele" placeholder="请输入11位手机号码">
                        </div>
                        <div class="pwd loginnp">
                            <span>*</span><label for="">密&nbsp;&nbsp;码：</label>
                            <input type="password" id="userPassword" name="userPassword" placeholder="请输入密码">
                        </div>
                        <div class="pwd loginnp">
                            <span>*</span><label for="">确认密码：</label>
                            <input type="password" id="cUserPassword" name="cUserPassword" placeholder="请确认密码">
                        </div>
                        <div class="name loginnp">
                            <label for="">用户名：</label>
                            <input type="text" id="userName" name="userName" class="f14" placeholder="可作为登录账号">
                        </div>
                        <div class="name loginnp">
                            <label for="">邮箱地址：</label>
                            <input type="email" id="userEmail" name="userEmail" class="f14" placeholder="可作为登录账号和密码找回凭证">
                        </div>
                        <div class="pwd loginnp">
                            <span>*</span><label for="">短信验证：</label>
                            <input type="number" id="number" class="f14" placeholder="请输入验证码">&nbsp;
                            <button type="submit" class=" num regb f14">获取验证码</button>
                        </div>
                        <div class="reg_bar">
                            <label for=""><input type="checkbox" name="terms" id="terms" value="">已阅读<a
                                    href="#"><span>华宇网上营业厅服务协议</span></a></label>
                            <br />
                            <div class="reg1">
                                <button type="submit" class=" regbt regb f14" onclick="admin_register()">注册</button>
                            </div>
                        </div>
                    </div>
                    </form>
                </div>
                <div class="reg_right">
                    <p class="regrp">已有账号，<a href="/tdhy/toLogin">立即去登录 >></a></p>
                    <p>注册成为<b>天地华宇会员</b>，您可以享受更多的服务</p>
                    <br />
                    <div class="regul">
                        <ul>
                            <li class="regrli">账号一体化</li>
                            <li class="regrli">快捷下单</li>
                            <li class="regrli">在线理赔</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <#include "${request.contextPath}/base/foot.html">
</body>
<script type="text/javascript">
function admin_register() {
    if($("#userName").val()==""){
		layer.msg('请输入账号');
        return false;
    }else if($("#userPassword").val()==""){
		layer.msg('请输入密码"');
        return false;
    }else if($("#userEmail").val()==""){
		layer.msg('请输入邮箱"');
        return false;
    }else if($("#userTele").val()==""){
		layer.msg('请输入手机号"');
        return false;
    }else{
    	var mail = $("#userEmail").val();
    	var regemail = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
    	var tele=$("#userTele").val();
    	var pwd=$("#userPassword").val();
    	var cpwd=$("#cUserPassword").val();
    	if(pwd!=cpwd){
    		layer.msg("输入密码不一致，请重新输入");
    		return false;
    	}else if(!(regemail.test(mail))){
    		layer.msg('请输入正确的邮箱"');
            return false;
    	}else if(tele.length!=11){
    		layer.msg('请输入正确的电话"');
            return false;
    	} 
    	else{
    		data={
   	    		"userName":$("#userName").val(),
   	    		"userPassword":$("#userPassword").val(),
   	    		"userEmail":$("#userEmail").val(),
   	    		"userTele":$("#userTele").val()
    		}
    		console.log($("#userName").val())
    		console.log(data)
     	    $.ajax({
    	    	"url" : "${request.contextPath}/tdhy/register",
    	        "contentType": "application/json",
    	    	"data":JSON.stringify(data),
    	    	"type" : "post",
    	    	"dataType" : "json",   
    	    	"success"	: function (resultMsg) {                        
        	    		console.log(resultMsg)
	    	    		if(resultMsg.code==1){
	    	        		layer.msg('验证邮件发送成功');
	    	    		}else{
	    	        		layer.msg('验证邮件发送失败，请重新注册');
	    	    		}
    	    		}
    	    	}); 
    	}
    }
}
</script>
</html>